ARD2  RC2
Airbag Reference Demonstrator using MPC5604P
freemaster_protocol.c
Go to the documentation of this file.
00001 /******************************************************************************
00002 *
00003 * Freescale Semiconductor Inc.
00004 * (c) Copyright 2004-2011 Freescale Semiconductor
00005 * ALL RIGHTS RESERVED.
00006 *
00007 ****************************************************************************/
00024 #include "freemaster.h"
00025 #include "freemaster_private.h"
00026 #include "freemaster_protocol.h"
00027 
00028 #if !FMSTR_DISABLE
00029 /**************************************************************************/
00035 FMSTR_BOOL FMSTR_Init(void)
00036 {   
00037 #if FMSTR_USE_TSA
00038     /* initialize TSA */
00039     FMSTR_InitTsa();
00040 #endif
00041 
00042 #if FMSTR_USE_SCOPE
00043     /* initialize Scope */
00044     FMSTR_InitScope();
00045 #endif
00046 
00047 #if FMSTR_USE_RECORDER
00048     /* initialize Recorder */
00049     FMSTR_InitRec();
00050 #endif
00051 
00052 #if FMSTR_USE_APPCMD
00053     /* initialize application commands */
00054     FMSTR_InitAppCmds();
00055 #endif
00056 
00057 #if FMSTR_USE_SFIO
00058     /* initialize SFIO encapsulation layer */
00059     FMSTR_InitSfio();
00060 #endif
00061 
00062 #if FMSTR_USE_PIPES
00063     /* initialize PIPES interface */
00064     FMSTR_InitPipes();
00065 #endif
00066 
00067 #if FMSTR_USE_CAN
00068     /* initialize CAN communication */
00069     FMSTR_InitCan();
00070 #endif  
00071 
00072 #if FMSTR_USE_PDBDM
00073     /* initialize Packet Driven BDM communication */
00074     FMSTR_InitPDBdm();
00075 #endif  
00076     
00077 #if FMSTR_USE_SERIAL
00078     /* initialize communication and start listening for commands */
00079     if (!FMSTR_InitSerial())
00080       return FMSTR_FALSE;
00081 #endif  
00082     return FMSTR_TRUE;
00083 }
00084 
00085 /**************************************************************************/
00099 FMSTR_BOOL FMSTR_ProtocolDecoder(FMSTR_BPTR pMessageIO)
00100 {
00101     FMSTR_BPTR pResponseEnd;
00102     FMSTR_U8 nCmd;
00103     
00104     /* no EX access by default */
00105     FMSTR_SetExAddr(FMSTR_FALSE);
00106     
00107     /* command code comes first in the message */
00108     /*lint -e{534} return value is not used */
00109     FMSTR_ValueFromBuffer8(&nCmd, pMessageIO);
00110 
00111     /* process command   */
00112     switch (nCmd)
00113     {
00114     
00115 #if FMSTR_USE_READVAR
00116 
00117         /* read byte */
00118 #if FMSTR_USE_EX_CMDS       
00119         case FMSTR_CMD_READVAR8_EX:
00120             FMSTR_SetExAddr(FMSTR_TRUE);
00121 #endif
00122 #if FMSTR_USE_NOEX_CMDS
00123         /*lint -fallthrough */
00124         case FMSTR_CMD_READVAR8:
00125 #endif          
00126             pResponseEnd = FMSTR_ReadVar(pMessageIO, 1U);
00127             break;
00128             
00129         /* read word */
00130 #if FMSTR_USE_EX_CMDS       
00131         case FMSTR_CMD_READVAR16_EX:
00132             FMSTR_SetExAddr(FMSTR_TRUE);
00133 #endif
00134 #if FMSTR_USE_NOEX_CMDS
00135         /*lint -fallthrough */
00136         case FMSTR_CMD_READVAR16:
00137 #endif
00138             pResponseEnd = FMSTR_ReadVar(pMessageIO, 2U);
00139             break;
00140             
00141         /* read dword */
00142 #if FMSTR_USE_EX_CMDS       
00143         case FMSTR_CMD_READVAR32_EX:
00144             FMSTR_SetExAddr(FMSTR_TRUE);
00145 #endif
00146 #if FMSTR_USE_NOEX_CMDS
00147         /*lint -fallthrough */
00148         case FMSTR_CMD_READVAR32:
00149 #endif
00150             pResponseEnd = FMSTR_ReadVar(pMessageIO, 4U);
00151             break;
00152 #endif /* FMSTR_USE_READVAR */
00153 
00154 #if FMSTR_USE_READMEM
00155 
00156         /* read a block of memory */
00157 #if FMSTR_USE_EX_CMDS       
00158         case FMSTR_CMD_READMEM_EX:
00159             FMSTR_SetExAddr(FMSTR_TRUE);
00160 #endif
00161 #if FMSTR_USE_NOEX_CMDS
00162         /*lint -fallthrough */
00163         case FMSTR_CMD_READMEM:
00164 #endif
00165             pResponseEnd = FMSTR_ReadMem(pMessageIO);
00166             break;
00167             
00168 #endif /* FMSTR_USE_READMEM */
00169 
00170 #if FMSTR_USE_SCOPE
00171 
00172         /* prepare scope variables */
00173 #if FMSTR_USE_EX_CMDS       
00174         case FMSTR_CMD_SETUPSCOPE_EX:
00175             FMSTR_SetExAddr(FMSTR_TRUE);
00176 #endif
00177 #if FMSTR_USE_NOEX_CMDS
00178         /*lint -fallthrough */
00179         case FMSTR_CMD_SETUPSCOPE:
00180 #endif
00181             pResponseEnd = FMSTR_SetUpScope(pMessageIO);
00182             break;  
00183             
00184         case FMSTR_CMD_READSCOPE:
00185             pResponseEnd = FMSTR_ReadScope(pMessageIO);
00186             break;
00187 #endif /* FMSTR_USE_SCOPE */
00188 
00189 #if FMSTR_USE_RECORDER
00190 
00191         /* get recorder status */
00192         case FMSTR_CMD_GETRECSTS:
00193             pResponseEnd = FMSTR_GetRecStatus(pMessageIO);
00194             break;
00195 
00196         /* start recorder */
00197         case FMSTR_CMD_STARTREC:
00198             pResponseEnd = FMSTR_StartRec(pMessageIO);
00199             break;
00200 
00201         /* stop recorder */
00202         case FMSTR_CMD_STOPREC:
00203             pResponseEnd = FMSTR_StopRec(pMessageIO);
00204             break;
00205 
00206         /* setup recorder */
00207 #if FMSTR_USE_EX_CMDS       
00208         case FMSTR_CMD_SETUPREC_EX:                 
00209             FMSTR_SetExAddr(FMSTR_TRUE);
00210 #endif
00211 #if FMSTR_USE_NOEX_CMDS
00212         /*lint -fallthrough */
00213         case FMSTR_CMD_SETUPREC:                    
00214 #endif
00215             pResponseEnd = FMSTR_SetUpRec(pMessageIO);
00216             break;
00217             
00218         /* get recorder buffer information (force EX instead of non-EX) */
00219 #if FMSTR_USE_EX_CMDS       
00220         case FMSTR_CMD_GETRECBUFF_EX:
00221             FMSTR_SetExAddr(FMSTR_TRUE);
00222 #elif FMSTR_USE_NOEX_CMDS
00223         /*lint -fallthrough */
00224         case FMSTR_CMD_GETRECBUFF:                  
00225 #endif
00226             pResponseEnd = FMSTR_GetRecBuff(pMessageIO);
00227             break; 
00228 #endif /* FMSTR_USE_RECORDER */
00229  
00230 #if FMSTR_USE_APPCMD
00231 
00232         /* accept the application command */
00233         case FMSTR_CMD_SENDAPPCMD:
00234             pResponseEnd = FMSTR_StoreAppCmd(pMessageIO);
00235             break;
00236 
00237         /* get the application command status */
00238         case FMSTR_CMD_GETAPPCMDSTS:
00239             pResponseEnd = FMSTR_GetAppCmdStatus(pMessageIO);
00240             break;
00241 
00242         /* get the application command data */
00243         case FMSTR_CMD_GETAPPCMDDATA:
00244             pResponseEnd = FMSTR_GetAppCmdRespData(pMessageIO);
00245             break;
00246 #endif /* FMSTR_USE_APPCMD */
00247 
00248 #if FMSTR_USE_WRITEMEM
00249 
00250         /* write a block of memory */
00251 #if FMSTR_USE_EX_CMDS       
00252         case FMSTR_CMD_WRITEMEM_EX:
00253             FMSTR_SetExAddr(FMSTR_TRUE);
00254 #endif          
00255 #if FMSTR_USE_NOEX_CMDS
00256         /*lint -fallthrough */
00257         case FMSTR_CMD_WRITEMEM:
00258 #endif
00259             pResponseEnd = FMSTR_WriteMem(pMessageIO);
00260             break;
00261 #endif /* FMSTR_USE_WRITEMEM */
00262 
00263 #if FMSTR_USE_WRITEMEMMASK
00264 
00265         /* write block of memory with a bit mask */
00266 #if FMSTR_USE_EX_CMDS       
00267         case FMSTR_CMD_WRITEMEMMASK_EX:
00268             FMSTR_SetExAddr(FMSTR_TRUE);
00269 #endif
00270 #if FMSTR_USE_NOEX_CMDS
00271         /*lint -fallthrough */
00272         case FMSTR_CMD_WRITEMEMMASK:
00273 #endif
00274             pResponseEnd = FMSTR_WriteMemMask(pMessageIO);
00275             break;
00276 #endif /* FMSTR_USE_WRITEMEMMASK */
00277             
00278 #if FMSTR_USE_WRITEVAR && FMSTR_USE_NOEX_CMDS
00279 
00280         /* write byte */
00281         case FMSTR_CMD_WRITEVAR8:
00282             pResponseEnd = FMSTR_WriteVar(pMessageIO, 1U);
00283             break;
00284 
00285         /* write word */
00286         case FMSTR_CMD_WRITEVAR16:
00287             pResponseEnd = FMSTR_WriteVar(pMessageIO, 2U);
00288             break;
00289 
00290         /* write dword */
00291         case FMSTR_CMD_WRITEVAR32:
00292             pResponseEnd = FMSTR_WriteVar(pMessageIO, 4U);
00293             break;
00294 #endif /* FMSTR_USE_WRITEVAR && FMSTR_USE_NOEX_CMDS */
00295 
00296 #if FMSTR_USE_WRITEVARMASK && FMSTR_USE_NOEX_CMDS
00297 
00298         /* write byte with mask */
00299         case FMSTR_CMD_WRITEVAR8MASK:
00300             pResponseEnd = FMSTR_WriteVarMask(pMessageIO, 1U);
00301             break;
00302 
00303         /* write word with mask */
00304         case FMSTR_CMD_WRITEVAR16MASK:
00305             pResponseEnd = FMSTR_WriteVarMask(pMessageIO, 2U);
00306             break;
00307 
00308 #endif /* FMSTR_USE_WRITEVARMASK && FMSTR_USE_NOEX_CMDS */
00309 
00310 #if FMSTR_USE_TSA
00311 
00312         /* get TSA table (force EX instead of non-EX) */
00313 #if FMSTR_USE_EX_CMDS       
00314         case FMSTR_CMD_GETTSAINFO_EX:
00315             FMSTR_SetExAddr(FMSTR_TRUE);
00316 #elif FMSTR_USE_NOEX_CMDS
00317         /*lint -fallthrough */
00318         case FMSTR_CMD_GETTSAINFO:
00319 #endif
00320             pResponseEnd = FMSTR_GetTsaInfo(pMessageIO);
00321             break;
00322             
00323 #if FMSTR_USE_EX_CMDS
00324         case FMSTR_CMD_GETSTRLEN_EX:
00325             FMSTR_SetExAddr(FMSTR_TRUE);
00326 #endif
00327 #if FMSTR_USE_NOEX_CMDS
00328         /*lint -fallthrough */
00329         case FMSTR_CMD_GETSTRLEN:
00330 #endif
00331             pResponseEnd = FMSTR_GetStringLen(pMessageIO);
00332             break;
00333 
00334 #endif /* FMSTR_USE_TSA */
00335 
00336 #if FMSTR_USE_BRIEFINFO
00337         /* retrieve a subset of board information structure */
00338         case FMSTR_CMD_GETINFOBRIEF:
00339 #else   
00340         /* retrieve board information structure */
00341         case FMSTR_CMD_GETINFO: 
00342 #endif
00343             pResponseEnd = FMSTR_GetBoardInfo(pMessageIO);
00344             break;
00345 
00346 #if FMSTR_USE_SFIO
00347         case FMSTR_CMD_SFIOFRAME_0:
00348         case FMSTR_CMD_SFIOFRAME_1:
00349             pResponseEnd = FMSTR_SfioFrame(pMessageIO);
00350             break;
00351         case FMSTR_CMD_SFIOGETRESP_0:
00352         case FMSTR_CMD_SFIOGETRESP_1:
00353             pResponseEnd = FMSTR_SfioGetResp(pMessageIO);
00354             break;
00355 #endif /* FMSTR_USE_SFIO */
00356 
00357 #if FMSTR_USE_PIPES
00358         case FMSTR_CMD_PIPE:
00359             pResponseEnd = FMSTR_PipeFrame(pMessageIO);
00360             break;
00361 #endif /* FMSTR_USE_PIPES */
00362 
00363         /* unknown command */
00364         default:
00365             pResponseEnd = FMSTR_ConstToBuffer8(pMessageIO, FMSTR_STC_INVCMD);
00366             break;          
00367     }
00368     
00369     /* anything to send back? */
00370     if(pResponseEnd != pMessageIO)
00371     {
00372         /*lint -e{946,960} subtracting pointers is appropriate here */
00373         FMSTR_SIZE8 nSize = (FMSTR_SIZE8)(pResponseEnd - pMessageIO);
00374         FMSTR_SendResponse(pMessageIO, nSize);
00375         return FMSTR_TRUE;
00376     }
00377     else
00378     {
00379         /* nothing sent out */
00380         return FMSTR_FALSE;
00381     }
00382 }
00383 
00384 /**************************************************************************/
00395 FMSTR_BPTR FMSTR_GetBoardInfo(FMSTR_BPTR pMessageIO)
00396 {
00397     FMSTR_BPTR pResponse = pMessageIO;
00398     FMSTR_U16 wTmp;
00399     FMSTR_U8 *pStr;
00400 
00401     pResponse = FMSTR_ConstToBuffer8(pResponse, FMSTR_STS_OK);              
00402     pResponse = FMSTR_ConstToBuffer8(pResponse, (FMSTR_U8)(FMSTR_PROT_VER));            /* protVer */
00403     pResponse = FMSTR_ConstToBuffer8(pResponse, (FMSTR_U8)(FMSTR_CFG_FLAGS));           /* cfgFlags */
00404     pResponse = FMSTR_ConstToBuffer8(pResponse, (FMSTR_U8)(FMSTR_CFG_BUS_WIDTH));       /* dataBusWdt */
00405     pResponse = FMSTR_ConstToBuffer8(pResponse, (FMSTR_U8)(FMSTR_GLOB_VERSION_MAJOR));  /* globVerMajor */
00406     pResponse = FMSTR_ConstToBuffer8(pResponse, (FMSTR_U8)(FMSTR_GLOB_VERSION_MINOR));  /* globVerMinor */
00407     pResponse = FMSTR_ConstToBuffer8(pResponse, (FMSTR_U8)(FMSTR_COMM_BUFFER_SIZE));    /* cmdBuffSize  */
00408 
00409     /* that is all for brief info */
00410 #if FMSTR_USE_BRIEFINFO
00411     FMSTR_UNUSED(pStr);
00412     FMSTR_UNUSED(wTmp);
00413     
00414 #else /* FMSTR_USE_BRIEFINFO */
00415 
00416 #if FMSTR_USE_RECORDER
00417 
00418     /* recorder buffer size is always measured in bytes */
00419     wTmp = FMSTR_GetRecBuffSize();
00420     wTmp *= FMSTR_CFG_BUS_WIDTH;
00421 
00422     /* send size and timebase    */
00423     pResponse = FMSTR_ValueToBuffer16(pResponse, wTmp);
00424     pResponse = FMSTR_ConstToBuffer16(pResponse, (FMSTR_U16) FMSTR_REC_TIMEBASE);
00425 #else /* FMSTR_USE_RECORDER */
00426 
00427     FMSTR_UNUSED(wTmp);
00428 
00429     /* recorder info zeroed */
00430     pResponse = FMSTR_ConstToBuffer16(pResponse, 0);
00431     pResponse = FMSTR_ConstToBuffer16(pResponse, 0);
00432 #endif /* FMSTR_USE_RECORDER */
00433 
00434 #if FMSTR_LIGHT_VERSION
00435 FMSTR_UNUSED(pStr);
00436     pResponse = FMSTR_SkipInBuffer(pResponse, (FMSTR_U8)FMSTR_DESCR_SIZE);
00437 #else
00438     /* description string */
00439     pStr = (FMSTR_U8*)  FMSTR_IDT_STRING;
00440     for(wTmp = 0U; wTmp < (FMSTR_U8)(FMSTR_DESCR_SIZE); wTmp++)
00441     {
00442         pResponse = FMSTR_ValueToBuffer8(pResponse, *pStr);
00443 
00444         /* terminating zero used to clear the remainder of the buffer */        
00445         if(*pStr)
00446         {
00447             pStr ++;
00448         }
00449     }
00450 #endif /* SEND_IDT_STRING */
00451     
00452 #endif /* FMSTR_USE_BRIEFINFO */
00453 
00454     return pResponse;   
00455 }
00456 
00457 /**************************************************************************/
00468 FMSTR_BPTR FMSTR_ReadMem(FMSTR_BPTR pMessageIO)
00469 {
00470     FMSTR_BPTR pResponse = pMessageIO;
00471     FMSTR_ADDR nAddr;
00472     FMSTR_U8 nSize;
00473 
00474     pMessageIO = FMSTR_SkipInBuffer(pMessageIO, 2U);
00475     pMessageIO = FMSTR_ValueFromBuffer8(&nSize, pMessageIO);
00476     pMessageIO = FMSTR_AddressFromBuffer(&nAddr, pMessageIO);
00477 
00478 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00479     if(!FMSTR_CheckTsaSpace(nAddr, (FMSTR_SIZE8) nSize, FMSTR_FALSE))
00480     {
00481         return FMSTR_ConstToBuffer8(pResponse, FMSTR_STC_EACCESS);
00482     }
00483 #endif
00484 
00485     /* check the response will safely fit into comm buffer */
00486     if(nSize > (FMSTR_U8)FMSTR_COMM_BUFFER_SIZE)
00487     {
00488         return FMSTR_ConstToBuffer8(pResponse, FMSTR_STC_RSPBUFFOVF);
00489     }
00490     
00491     /* success  */
00492     pResponse = FMSTR_ConstToBuffer8(pResponse, FMSTR_STS_OK);
00493     
00494     return FMSTR_CopyToBuffer(pResponse, nAddr, (FMSTR_SIZE8) nSize);
00495 }   
00496 
00497 /**************************************************************************/
00508 FMSTR_BPTR FMSTR_ReadVar(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nSize)
00509 {
00510     FMSTR_BPTR pResponse = pMessageIO;
00511     FMSTR_ADDR nAddr;
00512 
00513     pMessageIO = FMSTR_SkipInBuffer(pMessageIO, 1U);
00514     pMessageIO = FMSTR_AddressFromBuffer(&nAddr, pMessageIO);
00515 
00516 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00517     if(!FMSTR_CheckTsaSpace(nAddr, nSize, FMSTR_FALSE))
00518     {
00519         return FMSTR_ConstToBuffer8(pResponse, FMSTR_STC_EACCESS);
00520     }
00521 #endif
00522 
00523     /* success  */
00524     pResponse = FMSTR_ConstToBuffer8(pResponse, FMSTR_STS_OK);
00525     
00526     return FMSTR_CopyToBuffer(pResponse, nAddr, nSize);
00527 }   
00528 
00529 /**************************************************************************/
00540 FMSTR_BPTR FMSTR_WriteMem(FMSTR_BPTR pMessageIO)
00541 {
00542     FMSTR_BPTR pResponse = pMessageIO;
00543     FMSTR_ADDR nAddr;
00544     FMSTR_U8 nSize,nResponseCode;
00545 
00546     pMessageIO = FMSTR_SkipInBuffer(pMessageIO, 2U);
00547     pMessageIO = FMSTR_ValueFromBuffer8(&nSize, pMessageIO);
00548     pMessageIO = FMSTR_AddressFromBuffer(&nAddr, pMessageIO);
00549 
00550 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00551     if(!FMSTR_CheckTsaSpace(nAddr, (FMSTR_SIZE8) nSize, FMSTR_TRUE))
00552     {
00553         nResponseCode = FMSTR_STC_EACCESS;
00554         goto FMSTR_WriteMem_exit;
00555     }
00556 #endif
00557 
00558     /*lint -e{534} ignoring function return value */
00559     FMSTR_CopyFromBuffer(nAddr, pMessageIO, (FMSTR_SIZE8) nSize);
00560     nResponseCode = FMSTR_STS_OK;
00561 
00562 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00563 FMSTR_WriteMem_exit:
00564 #endif      
00565       
00566     return FMSTR_ConstToBuffer8(pResponse, nResponseCode);
00567 }
00568 
00569 /**************************************************************************/
00581 FMSTR_BPTR FMSTR_WriteVar(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nSize)
00582 {
00583     FMSTR_BPTR pResponse = pMessageIO;
00584     FMSTR_ADDR nAddr;
00585     FMSTR_U8 nResponseCode;
00586 
00587     pMessageIO = FMSTR_SkipInBuffer(pMessageIO, 1U);
00588     pMessageIO = FMSTR_AddressFromBuffer(&nAddr, pMessageIO);
00589 
00590 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00591     if(!FMSTR_CheckTsaSpace(nAddr, nSize, FMSTR_TRUE))
00592     {
00593         nResponseCode = FMSTR_STC_EACCESS;
00594         goto FMSTR_WriteVar_exit;
00595     }
00596 #endif
00597 
00598     /*lint -e{534} ignoring function return value */
00599     FMSTR_CopyFromBuffer(nAddr, pMessageIO, nSize);
00600     nResponseCode = FMSTR_STS_OK;
00601 
00602 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00603 FMSTR_WriteVar_exit:
00604 #endif
00605       
00606     return FMSTR_ConstToBuffer8(pResponse, nResponseCode);
00607 }
00608 
00609 
00610 /**************************************************************************/
00621 FMSTR_BPTR FMSTR_WriteMemMask(FMSTR_BPTR pMessageIO)
00622 {
00623     FMSTR_BPTR pResponse = pMessageIO;
00624     FMSTR_ADDR nAddr;
00625     FMSTR_U8 nSize,nResponseCode;
00626 
00627     pMessageIO = FMSTR_SkipInBuffer(pMessageIO, 2U);
00628     pMessageIO = FMSTR_ValueFromBuffer8(&nSize, pMessageIO);
00629     pMessageIO = FMSTR_AddressFromBuffer(&nAddr, pMessageIO);
00630 
00631 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00632     if(!FMSTR_CheckTsaSpace(nAddr, (FMSTR_SIZE8)nSize, FMSTR_TRUE))
00633     {
00634         nResponseCode = FMSTR_STC_EACCESS;
00635         goto FMSTR_WriteMemMask_exit;
00636     }
00637 #endif
00638 
00639 #if FMSTR_CFG_BUS_WIDTH > 1U
00640     /* size must be divisible by bus width (mask must not begin in half of memory word) */
00641     if(nSize % FMSTR_CFG_BUS_WIDTH)
00642     {
00643         nResponseCode = FMSTR_STC_INVSIZE;
00644         goto FMSTR_WriteMemMask_exit;
00645     }
00646 #endif
00647 
00648     /* put the data */
00649     FMSTR_CopyFromBufferWithMask(nAddr, pMessageIO, (FMSTR_SIZE8)nSize);
00650     nResponseCode = FMSTR_STS_OK;
00651 
00652 #if (FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY) || (FMSTR_CFG_BUS_WIDTH > 1U)
00653 FMSTR_WriteMemMask_exit:
00654 #endif  
00655       
00656     return FMSTR_ConstToBuffer8(pResponse, nResponseCode);
00657 }
00658 
00659 /**************************************************************************/
00671 FMSTR_BPTR FMSTR_WriteVarMask(FMSTR_BPTR pMessageIO, FMSTR_SIZE8 nSize)
00672 {
00673     FMSTR_BPTR pResponse = pMessageIO;
00674     FMSTR_ADDR nAddr;
00675     FMSTR_U8 nResponseCode;
00676     
00677     pMessageIO = FMSTR_SkipInBuffer(pMessageIO, 1U);
00678     pMessageIO = FMSTR_AddressFromBuffer(&nAddr, pMessageIO);
00679 
00680 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00681     if(!FMSTR_CheckTsaSpace(nAddr, nSize, FMSTR_TRUE))
00682     {
00683         nResponseCode = FMSTR_STC_EACCESS;
00684         goto FMSTR_WriteVarMask_exit;
00685     }
00686 #endif
00687 
00688     /* put the data */
00689     FMSTR_CopyFromBufferWithMask(nAddr, pMessageIO, nSize);         
00690     nResponseCode = FMSTR_STS_OK;
00691 
00692 #if FMSTR_USE_TSA && FMSTR_USE_TSA_SAFETY
00693 FMSTR_WriteVarMask_exit:
00694 #endif      
00695 
00696     return FMSTR_ConstToBuffer8(pResponse, nResponseCode);
00697 }
00698 
00699 
00700 /**************************************************************************/
00706 FMSTR_U16 FMSTR_StrLen(FMSTR_ADDR nAddr)
00707 {
00708     const FMSTR_U8* pStr;
00709     FMSTR_U16 nLen = 0U;
00710 
00711     #ifdef __HCS12X__
00712     /* convert from logical to global if needed */
00713     nAddr = FMSTR_FixHcs12xAddr(nAddr);
00714     #endif
00715 
00716     /*lint -e{923} casting address value to pointer */
00717     pStr = (const FMSTR_U8*) nAddr;
00718     
00719     while(*pStr++)
00720     {
00721         nLen++;
00722     }
00723         
00724     return nLen;
00725 }
00726 #else /* !FMSTR_DISABLE */
00727 
00728 /**************************************************************************/
00734 FMSTR_BOOL FMSTR_Init(void)
00735 {   
00736     return FMSTR_FALSE;
00737 }
00738 
00739 /*******************************************************************************
00740 *
00741 * @brief    API: Main "Polling" call from the application main loop
00742 *
00743 *******************************************************************************/
00744 
00745 void FMSTR_Poll(void)
00746 { 
00747 }
00748 
00749 /* HC12 interrupt routine declaration, must be in non-paged code memory */
00750 #if defined(FMSTR_PLATFORM_HC12)
00751     #include "non_bank.sgm"
00752 #endif
00753 
00754 /*******************************************************************************
00755 *
00756 * @brief    API: API: Main SCI / CAN Interrupt handler call
00757 *
00758 *******************************************************************************/
00759 #if !defined(FMSTR_PLATFORM_MQX) 
00760 #if defined(FMSTR_PLATFORM_MPC55xx)
00761 void FMSTR_Isr(unsigned long vec)
00762 {
00763     FMSTR_UNUSED(vec);
00764 }
00765 #else
00766 void FMSTR_Isr(void)
00767 {
00768 }
00769 #endif
00770 #endif
00771 
00772 #if defined(FMSTR_PLATFORM_HC12) || defined(FMSTR_PLATFORM_HC08) || defined(FMSTR_PLATFORM_MCF51xx)
00773 /*******************************************************************************
00774 *
00775 * @brief    API: API: The 2nd FMSTR interrupt handler 
00776 *
00777 *******************************************************************************/
00778 
00779 void FMSTR_Isr2(void)
00780 {
00781 }
00782 
00783 #endif
00784 
00785 /* restore HC12 code segment */
00786 #if defined(FMSTR_PLATFORM_HC12)
00787     #include "default.sgm"
00788 #endif
00789 
00790 #endif /* !FMSTR_DISABLE */